﻿using System.Web.Mvc;
using Tau.Service;
using Tau.ViewModels;

namespace Tau.Web.Controllers
{
    public class ProductController : Controller
    {
        public ActionResult Index()
        {
            var svc = new TauService();

            //Get categories 
            var productList = svc.GetPublicProductIndexList();

            return View("Index", productList);
        }

        public ActionResult GetProduct(int id)
        {
            var svc = new TauService();

            var product = svc.GetProduct(id);

            ViewBag.Title = string.Format("{0}, presented by Vesuvius Press", product.ProductData.ProductName);

            return View("GetProduct", product);
        }

        [HttpPost]
        public ActionResult Search(PublicProductSearch productSearch)
        {
            var svc = new TauService();

            PublicProductSearchResults searchResults = svc.GetFilteredProducts(productSearch);

            return View("SearchResults", searchResults);
        }
    }
}
